package
{
	import as3isolib.core.IIsoDisplayObject;
	import as3isolib.display.IsoView;
	import as3isolib.display.primitive.IsoBox;
	import as3isolib.display.scene.IsoGrid;
	import as3isolib.display.scene.IsoScene;
	import as3isolib.geom.IsoMath;
	import as3isolib.geom.Pt;
	
	import com.junkbyte.console.Cc;
	import com.junkbyte.console.ConsoleStyle;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.filters.GlowFilter;
	import flash.geom.Point;
	import flash.geom.Vector3D;
	import flash.utils.Timer;
	
	public class mmsiso extends Sprite
	{
		private var m_simulationTicker:Timer = new Timer(1000);
		public function mmsiso()
		{
			var initManager:InitializationManager = new InitializationManager(stage);
			initManager.addEventListener(Event.COMPLETE, onInitComplete);			
			
			initManager.start();
		}
		
		private function onInitComplete(e:Event):void{
			var terminal:Terminal = new Terminal(stage, inputReady);
			this.addChild(terminal.getDisplay());
			terminal.resizeToParent();
			
			startSimulation();
		}
		
		private function startSimulation():void{
			addEventListener(Event.ENTER_FRAME, onEnterFrame);			
		}
		
		private function addConsole():void{
			Cc.config.commandLineAllowed = true // Enables full commandLine features
			Cc.config.tracing = true; // also send traces to flash's normal trace()
			Cc.config.maxLines = 2000; // change maximum log lines to 2000, default is 1000
			Cc.config.style.traceFontSize = 8;
			Cc.config.style.menuFontSize = 8;
			
			
			Cc.startOnStage(Global.isoView,"`");
			Cc.width = 400;
			Cc.y = stage.height;			
		}

		
		private function inputReady(input:String):void{
			switch(input){
				case "sp": // show path
					Global.pathManager.showDebugRendering();
					break;	
			}
			
		}
		
		private function onEnterFrame(e:Event):void{
			Global.onEnterFrame(e);
		}
		
		private function createStore(x:Number,y:Number):GameObject{
			var store:Store = Store.createStore();
			store.model.location.x = x;
			store.model.location.y = y;
			
			Global.isoScene.addChild(store.isoDisplay);
			return store;
		}
	
	}
}